04. 定义函数 III

练习解决方案:readable_timedelta

def readable_timedelta(days):
    """Print the number of weeks and days in a number of days."""
    #to get the number of weeks we use integer division
    weeks = days // 7
    #to get the number of days that remain we use %, the modulus operator
    remainder = days % 7
    return "{} week(s) and {} day(s).".format(weeks, remainder)

真棒!你编写出了你的第一个函数。接下来你将学习和编写更多的函数!